using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Certs.Apis;

public static class CertsApiExtensions
{
    public static IServiceCollection AddCertsApi(this IServiceCollection serivces)
    {
        serivces.AddHttpClient("CertsApi").ConfigureHttpClient((sp, c) =>
        {
            var host = sp.GetRequiredService<IConfiguration>().GetValue("CertsApi:BaseAddress", string.Empty);
            c.BaseAddress = new Uri(host);
        });

        serivces.AddScoped<CertsClientProxy>();

        return serivces;
    }
}